﻿<%@ Page Language="C#" MasterPageFile="~/Shared/MainPage.Master" StylesheetTheme="GlobleTheme"
    AutoEventWireup="true" CodeBehind="ContractItemListSale.aspx.cs" Inherits="Runda.CMS.Portal.ContractManage.ContractItemListSale"
    Title="销售合同明细" %>

<%@ Register Assembly="RadGrid.Net2" Namespace="Telerik.WebControls" TagPrefix="rad" %>
<%@ Register Assembly="RadAjax.Net2" Namespace="Telerik.WebControls" TagPrefix="rad" %>
<%@ Register Assembly="RadCalendar.Net2" Namespace="Telerik.WebControls" TagPrefix="rad" %>
<%@ Register Assembly="RadInput.Net2" Namespace="Telerik.WebControls" TagPrefix="rad" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphHead" runat="server">
    <link href="../Content/global.css" rel="stylesheet" type="text/css" />

    <script src="../Content/global.js" type="text/javascript"></script>

    <link href="../Content/Menu/Menu.css" rel="stylesheet" type="text/css" />
    <link href="../Content/Tab/tabs.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript">
        function SelectInstrument() {
            var returnValue = openStdDlg("SelectContractItemInstrument.aspx?ContractID="+document.getElementById('<%=txtContractID.ClientID %>').value, "", 800, 600);
            RefreshItems();
        }

        function RefreshItems() {
            document.getElementById('<%=btnRefresh.ClientID %>').click();
        }

        function RowSelected(rowObject) {
            document.getElementById("<%=txtItemType.ClientID %>").value = rowObject.KeyValues["Type"];
            document.getElementById("<%=txtItemID.ClientID %>").value = rowObject.KeyValues["ItemID"];
            
            //RefreshItemPart();
        }

        function SelecContractGift() {

            if (document.getElementById('<%=txtContractID.ClientID %>').value == "") {
                alert('请先保存合同信息!');return;
            }
            var returnValue = openStdDlg("SelectGift.aspx?ContractID=" + document.getElementById('<%=txtContractID.ClientID %>').value, "", 800, 600);

            RefreshContractGift();
        }

        function RefreshContractGift() {
            if (document.getElementById('<%=txtContractID.ClientID %>').value == "") {
                alert('请先保存合同信息!!'); return;
            }
            document.getElementById('<%=btnRefreshContractGift.ClientID %>').click();
        }

        function RefreshItemPart() {
            document.getElementById('<%=btnResreshItemPart.ClientID %>').click();
        }

        function SelectParts() {
            if (document.getElementById('<%=txtItemID.ClientID %>').value == "") {
                alert('请先选择器械!!'); return;
            }
            var returnValue = openStdDlg("SelectContractItemPart.aspx?ItemID=" + document.getElementById('<%=txtItemID.ClientID %>').value, "", 800, 600);
            //RefreshItemPart();
        }
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphBody" runat="server">
    <rad:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <rad:AjaxSetting AjaxControlID="btnRefresh">
                <UpdatedControls>
                    <rad:AjaxUpdatedControl ControlID="gridContractItems" />
                </UpdatedControls>
            </rad:AjaxSetting> 
              <rad:AjaxSetting AjaxControlID="btnSaveContractItem">
                <UpdatedControls>
                    <rad:AjaxUpdatedControl ControlID="gridContractItems" LoadingPanelID="AjaxLoadingPanel"/>
                </UpdatedControls>
            </rad:AjaxSetting>
            <rad:AjaxSetting AjaxControlID="gridContractItems">
                <UpdatedControls>
                    <rad:AjaxUpdatedControl ControlID="txtItemID" />
                    <rad:AjaxUpdatedControl ControlID="txtItemType" />
                    <rad:AjaxUpdatedControl ControlID="gridGuaranty" />
                </UpdatedControls>
            </rad:AjaxSetting>
            <rad:AjaxSetting AjaxControlID="ddlPaymentType">
                <UpdatedControls>
                    <rad:AjaxUpdatedControl ControlID="ddlPaymentPeroid" />
                </UpdatedControls>
            </rad:AjaxSetting>
            <rad:AjaxSetting AjaxControlID="ddlPaymentPeroid">
                <UpdatedControls>
                    <rad:AjaxUpdatedControl ControlID="gridPayment" LoadingPanelID="AjaxLoadingPanel" />
                </UpdatedControls>
            </rad:AjaxSetting>
            <rad:AjaxSetting AjaxControlID="btnSavePayment">
                <UpdatedControls>
                    <rad:AjaxUpdatedControl ControlID="gridPayment" LoadingPanelID="AjaxLoadingPanel" />
                    <rad:AjaxUpdatedControl ControlID="ddlPaymentType" />
                    <rad:AjaxUpdatedControl ControlID="ddlPaymentPeroid" />
                </UpdatedControls>
            </rad:AjaxSetting>
            <rad:AjaxSetting AjaxControlID="btnRefreshContractGift">
                <UpdatedControls>
                    <rad:AjaxUpdatedControl ControlID="gridContractGift" LoadingPanelID="AjaxLoadingPanel" />
                </UpdatedControls>
            </rad:AjaxSetting>
            <rad:AjaxSetting AjaxControlID="btnSaveGift">
                <UpdatedControls>
                    <rad:AjaxUpdatedControl ControlID="gridContractGift" LoadingPanelID="AjaxLoadingPanel" />
                </UpdatedControls>
            </rad:AjaxSetting>
        </AjaxSettings>
    </rad:RadAjaxManager>
    <rad:AjaxLoadingPanel runat="server" ID="AjaxLoadingPanel">
        <img src="../Images/loadding_orange.gif" />
        加载中...
    </rad:AjaxLoadingPanel>
    <div class="area" id="areaForm">
        <div style="margin: 5px 0 5px 0">
        </div>
        <table class="mnubar" cellspacing="0" cellpadding="0" height="400px">
            <tbody>
                <tr>
                    <td style="padding-left: 5px" nowrap>
                        <b>合同明细项</b>
                    </td>
                    <td style="padding-left: 5px">
                        <img src="../Content/Grid/separator.gif">
                    </td>
                    <td class="icMenu" nowrap>
                    </td>
                    <td class="icMenu mnuRight" nowrap>
                        <span class="menu" onclick="return RefreshItems();">
                            <img class="mnuBtn" src="../Images/16_L_refresh.gif"><span class="mnuBtn">刷新</span></span>
                        <span class="menu" onclick="return SelectInstrument();">
                            <img class="mnuBtn" src="../Content/Grid/New_16_blue.gif" alt="添加机器、试剂等"><span class="mnuBtn">添加新项</span></span>
                    </td>
                </tr>
            </tbody>
        </table>
        <rad:RadGrid runat="server" ID="gridContractItems" Skin="OCM" AutoGenerateColumns="False"
            AllowSorting="false" GridLines="None" OnItemCommand="gridContractItems_ItemCommand"
            OnSortCommand="gridContractItems_SortCommand" OnItemDataBound="gridContractItems_ItemDataBound"
            EnableAJAX="True" EnableAJAXLoadingTemplate="True">
            <AJAXLoadingTemplate>
                加载中...
            </AJAXLoadingTemplate>
            <ClientSettings EnableClientKeyValues="true">
                <Selecting AllowRowSelect="true" />
                <ClientEvents OnRowSelected="RowSelected" />
            </ClientSettings>
            <MasterTableView DataKeyNames="ItemID,Type">
                <Columns>
                    <rad:GridBoundColumn DataField="InstrumentCode" HeaderText="编码">
                    </rad:GridBoundColumn>
                    <rad:GridBoundColumn DataField="InstrumentName" HeaderText="名称">
                    </rad:GridBoundColumn>
                    <rad:GridBoundColumn DataField="ItemStandard" HeaderText="规格">
                    </rad:GridBoundColumn>
                    <rad:GridBoundColumn DataField="unit" HeaderText="单位">
                    </rad:GridBoundColumn>
                    <rad:GridBoundColumn DataField="vendor" HeaderText="厂家">
                    </rad:GridBoundColumn>
                    <rad:GridTemplateColumn HeaderText="数量">
                        <ItemTemplate>
                            <asp:TextBox ID="txtCount" runat="server" Width="40px" CssClass="input" Text='<%#Eval("Count") %>'></asp:TextBox>
                        </ItemTemplate>
                    </rad:GridTemplateColumn>
                    <rad:GridTemplateColumn HeaderText="销售价">
                        <ItemTemplate>
                            <asp:TextBox ID="txtPrice" runat="server" Width="80px" CssClass="input" Text='<%#Eval("Price") %>'></asp:TextBox>
                        </ItemTemplate>
                    </rad:GridTemplateColumn>
                    <rad:GridTemplateColumn HeaderText="保修年限">
                        <ItemTemplate>
                            <asp:TextBox ID="txtGuaranteeYear" runat="server" Width="40px" CssClass="input" Text='<%#Eval("GuaranteeYear") %>'></asp:TextBox>
                        </ItemTemplate>
                    </rad:GridTemplateColumn>
                    <rad:GridTemplateColumn HeaderText="操作">
                        <ItemTemplate>
                            <asp:LinkButton ID="lnkbtnSave" runat="server" Text="保存" CommandName="save"></asp:LinkButton>
                        </ItemTemplate>
                    </rad:GridTemplateColumn>
                    <rad:GridButtonColumn CommandName="delete" Text="删除">
                    </rad:GridButtonColumn>
                </Columns>
            </MasterTableView>
        </rad:RadGrid>
        <div style="text-align:center;MARGIN-RIGHT: auto; MARGIN-LEFT: auto;">
            <asp:Button ID="btnSaveContractItem" runat="server" Text="保存" CssClass="button" 
                onclick="btnSaveContractItem_Click" />
        </div>
        <div style="border-bottom: #c2c2bf 1px solid; border-top: #969693 1px solid">
        </div>
        <div style="margin: 5px 0 5px 0">
        </div>
        <table class="mnubar" cellspacing="0" cellpadding="0" height="400px">
            <tbody>
                <tr>
                    <td style="padding-left: 5px" nowrap>
                        <b>付款信息</b>
                    </td>
                    <td style="padding-left: 5px">
                        <img src="../Content/Grid/separator.gif">
                    </td>
                    <td class="icMenu" nowrap>
                    </td>
                    <td class="icMenu mnuRight" nowrap>
                    </td>
                </tr>
            </tbody>
        </table>
        <div style="display: inline" id="appForm_tab0" class="tab">
            <table border="0" width="100%">
                <colgroup>
                    <col width="120px" />
                    <col />
                    <col width="120px" />
                    <col />
                </colgroup>
                <tr>
                    <td>
                        付款方式
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlPaymentType" runat="server" CssClass="selectBox" AutoPostBack="True"
                            OnSelectedIndexChanged="ddlPaymentType_SelectedIndexChanged">
                        </asp:DropDownList>
                    </td>
                    <td>
                        付款期数
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlPaymentPeroid" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlPaymentPeroid_SelectedIndexChanged">
                            <asp:ListItem Text="1" Value="1"></asp:ListItem>
                            <asp:ListItem Text="2" Value="2"></asp:ListItem>
                            <asp:ListItem Text="3" Value="3"></asp:ListItem>
                            <asp:ListItem Text="4" Value="4"></asp:ListItem>
                            <asp:ListItem Text="5" Value="5"></asp:ListItem>
                            <asp:ListItem Text="6" Value="6"></asp:ListItem>
                            <asp:ListItem Text="7" Value="7"></asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        <rad:RadGrid runat="server" ID="gridPayment" Skin="OCM" AutoGenerateColumns="False"
                            AllowSorting="false" GridLines="None" EnableAJAX="true" AllowPaging="false" EnableAJAXLoadingTemplate="true"
                            OnDeleteCommand="gridPayment_DeleteCommand" OnItemDataBound="gridPayment_ItemDataBound">
                            <AJAXLoadingTemplate>
                                <img src="../Images/loadding_orange.gif" />
                                加载中...
                            </AJAXLoadingTemplate>
                            <MasterTableView DataKeyNames="PaymentID">
                                <Columns>
                                    <rad:GridTemplateColumn HeaderText="支付日期">
                                        <ItemTemplate>
                                            <rad:RadDatePicker ID="txtPayDate" runat="server" Skin="Vista">
                                            </rad:RadDatePicker>
                                        </ItemTemplate>
                                    </rad:GridTemplateColumn>
                                    <rad:GridTemplateColumn HeaderText="支付金额">
                                        <ItemTemplate>
                                            <rad:RadNumericTextBox ID="txtPayAmount" runat="server" Skin="Office2007">
                                            </rad:RadNumericTextBox>
                                        </ItemTemplate>
                                    </rad:GridTemplateColumn>
                                    <rad:GridTemplateColumn HeaderText="删除">
                                        <ItemTemplate>
                                            <asp:LinkButton ID="lnkbtnDelete" runat="server" CommandName="delete">删除</asp:LinkButton>
                                        </ItemTemplate>
                                    </rad:GridTemplateColumn>
                                </Columns>
                            </MasterTableView>
                        </rad:RadGrid>
                    </td>
                </tr>
                <tr>
                    <td colspan="4" align="center">
                        <asp:Button ID="btnSavePayment" runat="server" Text="保存" CssClass="button" OnClick="btnSavePayment_Click" />
                    </td>
                </tr>
            </table>
        </div>
        <div style="border-bottom: #c2c2bf 1px solid; border-top: #969693 1px solid">
        </div>
        <div style="margin: 5px 0 5px 0">
        </div>
        <table class="mnubar" cellspacing="0" cellpadding="0" height="400px">
            <tbody>
                <tr>
                    <td style="padding-left: 5px" nowrap>
                        <b>配套商品</b>
                    </td>
                    <td style="padding-left: 5px">
                        <img src="../Content/Grid/separator.gif">
                    </td>
                    <td class="icMenu" nowrap>
                    </td>
                    <td class="icMenu mnuRight" nowrap>
                        <span class="menu" onclick="return SelecContractGift();">
                            <img class="mnuBtn" src="../Content/Grid/New_16_blue.gif" alt="选择配套商品"><span class="mnuBtn">添加新项</span></span>
                    </td>
                </tr>
            </tbody>
        </table>
        <rad:RadGrid runat="server" ID="gridContractGift" Skin="OCM" AutoGenerateColumns="False"
            AllowSorting="false" GridLines="None" EnableAJAX="true" 
            AllowPaging="false" EnableAJAXLoadingTemplate="true"
            OnDeleteCommand="gridContractGift_DeleteCommand" 
            onitemdatabound="gridContractGift_ItemDataBound">
            <AJAXLoadingTemplate>
                <img src="../Images/loadding_orange.gif" />
                加载中...
            </AJAXLoadingTemplate>
            <MasterTableView DataKeyNames="GiftID">
                <Columns>
                    <rad:GridBoundColumn HeaderText="商品编码" DataField="InstrumentCode">
                    </rad:GridBoundColumn>
                    <rad:GridBoundColumn HeaderText="商品名称" DataField="InstrumentName">
                    </rad:GridBoundColumn>
                    <rad:GridBoundColumn HeaderText="规格" DataField="instrumentStandard">
                    </rad:GridBoundColumn>
                    <rad:GridBoundColumn HeaderText="单位" DataField="Unit">
                    </rad:GridBoundColumn>
                    <rad:GridTemplateColumn HeaderText="成本">
                        <ItemTemplate>
                                <rad:RadNumericTextBox ID="txtCost" runat="server" Skin="Office2007">
                                </rad:RadNumericTextBox>
                        </ItemTemplate>
                    </rad:GridTemplateColumn>
                    <rad:GridTemplateColumn HeaderText="删除">
                        <ItemTemplate>
                            <asp:LinkButton ID="lnkbtnDelete" runat="server" CommandName="delete">删除</asp:LinkButton>
                        </ItemTemplate>
                    </rad:GridTemplateColumn>
                </Columns>
            </MasterTableView>
        </rad:RadGrid>
        <div style="text-align:center;MARGIN-RIGHT: auto; MARGIN-LEFT: auto;">
            <asp:Button ID="btnSaveGift" runat="server" Text="保存" CssClass="button" OnClick="btnSaveGift_Click" />
        </div>
    </div>
    <asp:HiddenField ID="txtContractID" runat="server" />
    <asp:HiddenField ID="txtItemID" runat="server" />
    <asp:HiddenField ID="txtItemType" runat="server" />
    <asp:Button ID="btnRefresh" runat="server" Text="刷新" OnClick="btnRefresh_Click" Style="display: none" />
    <asp:Button ID="btnRefreshContractGift" runat="server" Text="刷新" OnClick="btnRefreshContractGift_Click" Style="display: none" />
    <asp:Button ID="btnResreshItemPart" runat="server" Text="刷新" onclick="btnResreshItemPart_Click" Style="display: none"/>
</asp:Content>
